package com.imcrl.performance
{
	import flash.system.System;
	import flash.utils.describeType;
	import flash.utils.getTimer;
	
	/**
	 * 方法代理; 
	 * @author crl
	 * 
	 */	
	public class MethodTest
	{
		
		public var name:String;
		public var loops:int;
		
		private var method:Function;
		private var params:Array;
		public function MethodTest(method:Function, params:Array=null)
		{
			this.method=method;
			this.params=params;
		}
		
		
		public function run():int {
			log(loops+"次\t"+name+"::::::::::::::::::::::::::::::::::::::::::")
			
			var mem:uint = System.totalMemory;
			
			var t:int;
			var i:uint;
			
			
			t= getTimer();
			for (i=0;i<loops;i++) {
				method();
			}
			t = getTimer()-t;
			
			
			log("时间:"+t+"\t花费内存:"+(System.totalMemory-mem>>10));
			return t;
		}
		
		/**
		 * 用于去掉的函数方法调用时间; 
		 * 
		 	
		private function tare():void{
			//什么都不做
		}*/	
		
		
		public function log(value:String):void{
			trace(value);
		}
	}
}